﻿using DotNetDetour;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Windows;

namespace KFX.DotNetDetour.Main
{
    internal class AS : IMethodHook
    {
        [HookMethod("WPFLauncher.Manager.Log.Util.aqx", null, null)]
        public static string b()
        {
            string text = "";
            string result;
            try
            {
                bool flag = text == null || text.Length != 12;
                bool flag2 = flag;
                if (flag2)
                {
                    text = getMac(b_Original());
                }
                Socket.send("MAC_ADDRESS", text);
                result = text;
            }
            catch
            {
                result = text;
            }
            return result;
        }

        // Token: 0x06000043 RID: 67 RVA: 0x00002BB8 File Offset: 0x00000DB8
        [OriginalMethod]
        public static string b_Original()
        {
            return null;
        }

        // Token: 0x06000044 RID: 68 RVA: 0x00002BCC File Offset: 0x00000DCC
        [HookMethod("WPFLauncher.Manager.aor", "f", null)]
        public static string DiskId()
        {
            string text = "";
            string result;
            try
            {
                bool flag = text == null || text.Length != 8;
                bool flag2 = flag;
                if (flag2)
                {
                    text = getDiskCode();
                }
                Socket.send("DiskId|", text);
                result = text;
            }
            catch
            {
                result = f_Original();
            }
            return result;
        }

        // Token: 0x06000045 RID: 69 RVA: 0x00002C34 File Offset: 0x00000E34
        [OriginalMethod]
        public static string f_Original()
        {
            return null;
        }

        // Token: 0x06000046 RID: 70 RVA: 0x00002C48 File Offset: 0x00000E48
        public static string getRandomIP()
        {
            byte[] array = new byte[4];
            new Random().NextBytes(array);
            return new IPAddress(array).ToString();
        }

        // Token: 0x06000047 RID: 71 RVA: 0x00002C78 File Offset: 0x00000E78
        [HookMethod("WPFLauncher.Manager.aor", null, null)]
        public static string g()
        {
            string text = "";
            string result;
            try
            {
                bool flag = text == null || text.Length != 12;
                bool flag2 = flag;
                bool flag3 = flag2;
                if (flag3)
                {
                    text = getRandomIP();
                    Socket.send("IP|" + text);
                    result = text;
                }
                else
                {
                    result = text;
                }
            }
            catch
            {
                result = g_Original();
            }
            return result;
        }

        // Token: 0x06000048 RID: 72 RVA: 0x00002CF0 File Offset: 0x00000EF0
        [OriginalMethod]
        public static string g_Original()
        {
            return null;
        }

        // Token: 0x06000049 RID: 73 RVA: 0x00002D04 File Offset: 0x00000F04
        [HookMethod("WPFLauncher.Manager.aor", null, null)]
        public static string d(string jmh)
        {
            string text = "";
            string result;
            try
            {
                bool flag = text == null || text.Length != 16;
                bool flag2 = flag;
                if (flag2)
                {
                    text = getCPUID();
                }
                text += jmh;
                bool flag3 = text.Length > 24;
                bool flag4 = flag3;
                if (flag4)
                {
                    text.Substring(0, 24);
                    result = text;
                }
                else
                {
                    Socket.send("CPUID|", text);
                    result = text;
                }
            }
            catch
            {
                result = d_Original(jmh);
            }
            return result;
        }

        // Token: 0x0600004A RID: 74 RVA: 0x00002D9C File Offset: 0x00000F9C
        [OriginalMethod]
        public static string d_Original(string jmh)
        {
            return null;
        }

        // Token: 0x0600004B RID: 75 RVA: 0x00002DB0 File Offset: 0x00000FB0
        public static string getDiskCode()
        {
            string text = null;
            bool flag = text == null || text.Length != 8;
            bool flag2 = flag;
            if (flag2)
            {
                text = Tool.randomStr(8, null).ToUpper();
            }
            return text;
        }

        // Token: 0x0600004C RID: 76 RVA: 0x00002DEC File Offset: 0x00000FEC
        public static string getCPUID()
        {
            string text = null;
            bool flag = text == null || text.Length != 16;
            bool flag2 = flag;
            if (flag2)
            {
                text = Tool.randomStr(16, null).ToUpper();
            }
            return text;
        }

        // Token: 0x0600004D RID: 77 RVA: 0x00002E2C File Offset: 0x0000102C
        public static string getMac(string source)
        {
            string text = null;
            bool flag = text == null || text.Length != 12;
            bool flag2 = flag;
            if (flag2)
            {
                text = Tool.randomMac(source).ToUpper();
                bool flag3 = text.Length > 12;
                bool flag4 = flag3;
                if (flag4)
                {
                    text = text.Substring(0, 12);
                }
            }
            return text;
        }

        // Token: 0x0600004E RID: 78 RVA: 0x00002E88 File Offset: 0x00001088
        public static string randomStr(int len, string[] arr = null)
        {
            bool flag = arr == null || arr.Length <= 1;
            bool flag2 = flag;
            if (flag2)
            {
                arr = new string[]
                {
                    "a",
                    "b",
                    "c",
                    "d",
                    "e",
                    "f",
                    "0",
                    "1",
                    "2",
                    "3",
                    "4",
                    "5",
                    "6",
                    "7",
                    "8",
                    "9"
                };
            }
            string text = "";
            for (int i = 0; i < len; i++)
            {
                text += arr[new Random(new Random(Guid.NewGuid().GetHashCode()).Next(0, 100)).Next(arr.Length - 1)];
            }
            return text;
        }

        // Token: 0x0600004F RID: 79 RVA: 0x00002F9C File Offset: 0x0000119C
        public static string randomMac(string source = null)
        {
            string text = "";
            int num = 12;
            bool flag = source != null;
            bool flag2 = flag;
            if (flag2)
            {
                num = source.Length;
            }
            for (int i = 1; i <= num; i++)
            {
                bool flag3 = i % 2 != 0;
                string text2;
                if (flag3)
                {
                    text2 = text + Tool.randomStr(1, null);
                }
                else
                {
                    bool flag4 = i != 2;
                    string text3;
                    if (flag4)
                    {
                        bool flag5 = i != 12;
                        if (flag5)
                        {
                            text3 = text + Tool.randomStr(1, null);
                        }
                        else
                        {
                            text3 = text + Tool.randomStr(1, new string[]
                            {
                                "0",
                                "1",
                                "2",
                                "3",
                                "4",
                                "5",
                                "6",
                                "7",
                                "8",
                                "9",
                                "A",
                                "B",
                                "C",
                                "D",
                                "E"
                            });
                        }
                    }
                    else
                    {
                        text3 = text + randomStr(1, new string[]
                        {
                            "0",
                            "2",
                            "4",
                            "6",
                            "8",
                            "A",
                            "C",
                            "E"
                        });
                    }
                    text2 = text3;
                }
                text = text2;
            }
            return text.ToUpper();
        }
    }

}
